   $(document).ready(function(){
        $('#using_json').jstree({
            'core' : {
            'data' : [               
                {
                    'text': '电动物流车A组',
                    'state': {
                        'opened': true
                    },
                    'children': [
                        {
                            'text': '电动物流车001',                       
                            'state': {
                                'opened': true
                            }
                        },
                        {
                            'text': '电动物流车002',                     
                            'state': {
                                'opened': true
                            }
                        },
						 {
                            'text': '电动物流车003',                       
                            'state': {
                                'opened': true
                            }
                        },
						 {
                            'text': '电动物流车004',                       
                            'state': {
                                'opened': true
                            }
                        },
						 {
                            'text': '电动物流车005',                       
                            'state': {
                                'opened': true
                            }
                        },                      
                    ]
                },
                {
				   'text':'电动物流车B组',
				   'state': {
                                'opened': true
                            },
				'children': [
                        {
                            'text': '电动物流车006',                       
                            'state': {
                                'opened': true
                            }
                        },
						 {
                            'text': '电动物流车007',                       
                            'state': {
                                'opened': true
                            }
						 },
			               ],
				},
				
                '电动物流车C组',
                '电动物流车D组',
                '电动物流车E组',
            ]
        } });
		
		test();
	
		$('#qc_table').bootstrapTable({
			//url: 'data1.json',		  
		   columns: [{
				field: 'searchType',
				title: '条件类型'
			}, {
				field: 'typeContent',
				title: '条件内容'
			}],
			data:jsonstr_qc2
		});
	

	
//实时告警table列表
//车体告警
		$('#carAram_table').bootstrapTable({
			//url: 'data1.json',		  
		   pagination:true,                  
           pageNumber:1,                    
           pageSize: 6,                       
           pageList: [10, 25, 50, 100],       
 
		   columns: [
		    {
				field: 'id',
				title: '序号'
			},{
				field: 'dateTime',
				title: '时间'
			}, {
				field: 'indi',
				title: '指标'
			}, {
				field: 'indiValue',
				title: '指标值'
			},{
				field: 'alarmContent',
				title: '告警内容'
			}],
			data: [{
				id:'1',
				dateTime: '2017-08-08 14:30:00',
				indi: '电机电压',
				indiValue: '25',				
				alarmContent: '电机电压越限，超过上限'				
			},
			{
				id:'2',
				dateTime: '2017-08-08 14:30:00',
				indi: '总电压',
				indiValue: '15',				
				alarmContent: '总电压越限，超过上限'	
			},
			{
				id:'3',
				dateTime: '2017-08-08 14:30:00',
				indi: '总电流',
				indiValue: '65',				
				alarmContent: '总电流越限，低于下限'	
			},
			{
				id:'4',
				dateTime: '2017-08-08 14:30:00',
				indi: '总电流',
				indiValue: '65',				
				alarmContent: '总电流越限，低于下限'	
			},{
				id:'5',
				dateTime: '2017-08-08 14:30:00',
				indi: '总电流',
				indiValue: '65',				
				alarmContent: '总电流越限，低于下限'	
			},
            {
				id:'6',
				dateTime: '2017-08-08 14:30:00',
				indi: '电机电压',
				indiValue: '25',				
				alarmContent: '电机电压越限，超过上限'				
			},
            {
				id:'7',
				dateTime: '2017-08-08 14:30:00',
				indi: '电机电压',
				indiValue: '25',				
				alarmContent: '电机电压越限，超过上限'				
			},
            {
				id:'8',
				dateTime: '2017-08-08 14:30:00',
				indi: '电机电压',
				indiValue: '25',				
				alarmContent: '电机电压越限，超过上限'				
			}		
			]
		});
//温湿度告警		
		$('#thAram_table').bootstrapTable({
			//url: 'data1.json',		  
		   pagination:true,                  
           pageNumber:1,                      
           pageSize: 6,                       
           pageList: [10, 25, 50, 100],       
 
		   columns: [
		    {
				field: 'id',
				title: '序号'
			},{
				field: 'dateTime',
				title: '时间'
			}, {
				field: 'indi',
				title: '指标'
			}, {
				field: 'indiValue',
				title: '指标值'
			},{
				field: 'alarmContent',
				title: '告警内容'
			}],
			data: [{
				id:'1',
				dateTime: '2017-08-08 14:30:00',
				indi: '温度1',
				indiValue: '2&#176;C',				
				alarmContent: '温度越限，超过下限'				
			},
			{
				id:'2',
				dateTime: '2017-08-08 14:30:00',
				indi: '温度1',
				indiValue: '8&#176;C',				
				alarmContent: '温度越限，超过上限'	
			},
			{
				id:'3',
				dateTime: '2017-08-08 14:30:00',
				indi: '湿度',
				indiValue: '40%RH',				
				alarmContent: '湿度越限，超过上限'	
			},
			{
				id:'4',
				dateTime: '2017-08-08 14:30:00',
				indi: '温度2',
				indiValue: '8&#176;C',				
				alarmContent: '温度越限，超过上限'	
			},{
				id:'5',
				dateTime: '2017-08-08 14:30:00',
				indi: '湿度',
				indiValue: '60%RH',				
				alarmContent: '湿度越限，超过上限'		
			},
            {
				id:'6',
				dateTime: '2017-08-08 14:30:00',
				indi: '温度3',
				indiValue: '8&#176;C',				
				alarmContent: '温度越限，超过上限'			
			},
            {
				id:'7',
				dateTime: '2017-08-08 14:30:00',
				indi: '温度1',
				indiValue: '8&#176;C',				
				alarmContent: '温度越限，超过上限'				
			},
            {
				id:'8',
				dateTime: '2017-08-08 14:30:00',
				indi: '温度2',
				indiValue: '8&#176;C',				
				alarmContent: '温度越限，超过上限'			
			}		
			]
		});
		
//通信状态告警		
		$('#contactAram_table').bootstrapTable({
			//url: 'data1.json',		  
		   pagination:true,                  
           pageNumber:1,                      
           pageSize: 6,                       
           pageList: [10, 25, 50, 100],       
 
		   columns: [
		    {
				field: 'id',
				title: '序号'
			},{
				field: 'dateTime',
				title: '时间'
			}, {
				field: 'indi',
				title: '指标'
			}, {
				field: 'indiValue',
				title: '指标值'
			},{
				field: 'alarmContent',
				title: '告警内容'
			}],
			data: [{
				id:'1',
				dateTime: '2017-08-08 14:30:00',
				indi: '通信状态',
				indiValue: '离线',				
				alarmContent: '车辆离线'				
			},
			{
				id:'2',
				dateTime: '2017-08-08 14:30:00',
				indi: '通信状态',
				indiValue: '离线',				
				alarmContent: '车辆离线'
			},
			{
				id:'3',
				dateTime: '2017-08-08 14:30:00',
				indi: '通信状态',
				indiValue: '离线',				
				alarmContent: '车辆离线'	
			},
			{
				id:'4',
				dateTime: '2017-08-08 14:30:00',
				indi: '通信状态',
				indiValue: '离线',				
				alarmContent: '车辆离线'
			},{
				id:'5',
				dateTime: '2017-08-08 14:30:00',
				indi: '通信状态',
				indiValue: '离线',				
				alarmContent: '车辆离线'	
			},
            {
				id:'6',
				dateTime: '2017-08-08 14:30:00',
				indi: '通信状态',
				indiValue: '离线',				
				alarmContent: '车辆离线'			
			},
            {
				id:'7',
				dateTime: '2017-08-08 14:30:00',
				indi: '通信状态',
				indiValue: '离线',				
				alarmContent: '车辆离线'			
			},
            {
				id:'8',
				dateTime: '2017-08-08 14:30:00',
				indi: '通信状态',
				indiValue: '离线',				
				alarmContent: '车辆离线'		
			}		
			]
		});	
//终端故障告警
        $('#deviceAram_table').bootstrapTable({
			//url: 'data1.json',		  
		   pagination:true,                  
           pageNumber:1,                       
           pageSize: 6,                       
           pageList: [10, 25, 50, 100],       
 
		   columns: [
		    {
				field: 'id',
				title: '序号'
			},{
				field: 'dateTime',
				title: '时间'
			},{
				field: 'alarmContent',
				title: '告警内容'
			}],
			data: [{
				id:'1',
				dateTime: '2017-08-08 14:30:00',							
				alarmContent: '1号传感器故障'				
			},
			{
				id:'2',			
				dateTime: '2017-08-08 14:30:00',							
				alarmContent: '2号传感器故障'	
			},
			{
				id:'3',
			    dateTime: '2017-08-08 14:30:00',							
				alarmContent: '3号传感器故障'	
			},
			{
				id:'4',
				dateTime: '2017-08-08 14:30:00',							
				alarmContent: '4号传感器故障'	
			},{
				id:'5',
				dateTime: '2017-08-08 14:30:00',							
				alarmContent: '5号传感器故障'	
			},
            {
				id:'6',
			    dateTime: '2017-08-08 14:30:00',							
				alarmContent: '6号传感器故障'				
			},
            {
				id:'7',
				dateTime: '2017-08-08 14:30:00',							
				alarmContent: '7号传感器故障'				
			},
            {
				id:'8',
				dateTime: '2017-08-08 14:30:00',							
				alarmContent: '8号传感器故障'			
			}		
			]
		});	
//电子围栏告警
  $('#fenceAram_table').bootstrapTable({
			//url: 'data1.json',		  
		   pagination:true,                  
           pageNumber:1,                     
           pageSize: 6,                      
           pageList: [10, 25, 50, 100],        
 
		   columns: [
		    {
				field: 'id',
				title: '序号'
			},{
				field: 'dateTime',
				title: '时间'
			},{
				field: 'fenceNo',
				title: '围栏编号'
			},{
				field: 'alarmContent',
				title: '告警内容'
			}],
			data: [{
				id:'1',
				dateTime: '2017-08-08 14:30:00',
				fenceNo:'WL1001',
				alarmContent: '驶出报警'				
			},
			{
				id:'2',			
				dateTime: '2017-08-08 14:30:00',
				fenceNo:'WL1002',
				alarmContent: '驶入报警'
			},
			{
				id:'3',
			    dateTime: '2017-08-08 14:30:00',
				fenceNo:'WL1003',
				alarmContent: '驶出报警'
			},
			{
				id:'4',
				dateTime: '2017-08-08 14:30:00',
				fenceNo:'WL1004',
				alarmContent: '驶出报警'
			},{
				id:'5',
				dateTime: '2017-08-08 14:30:00',
				fenceNo:'WL1005',
				alarmContent: '驶出报警'	
			},
            {
				id:'6',
			    dateTime: '2017-08-08 14:30:00',
				fenceNo:'WL1006',
				alarmContent: '驶出报警'				
			},
            {
				id:'7',
				dateTime: '2017-08-08 14:30:00',
				fenceNo:'WL1007',
				alarmContent: '驶出报警'				
			},
            {
				id:'8',
				dateTime: '2017-08-08 14:30:00',
				fenceNo:'WL1008',
				alarmContent: '驶出报警'		
			}		
			]
		});		
    });

	
var jsonstr_qc=[{'searchType':'通信状态','typeContent':[{'typeContent':'在线'},{'typeContent':'离线'}]},{'searchType':'负载状态','typeContent':[{'typeContent':'空载'},{'typeContent':'负载'}]},{'searchType':'充电状态','typeContent':[{'typeContent':'充电中'},{'typeContent':'未充电'}]},
{'searchType':'告警类型','typeContent':[{'typeContent':'车体告警'},{'typeContent':'温湿度告警'},{'typeContent':'通信状态告警'},{'typeContent':'终端故障告警'},{'typeContent':'电子围栏告警'}]}];

var jsonstr_qc2=[];	
	
//测试条件
 function test(){	
	$.each(jsonstr_qc,function(k,v){
		var tbData = {};   //对象
			tbData.searchType = jsonstr_qc[k].searchType;
		var content = jsonstr_qc[k].typeContent;
		var ctt="";
		    $.each(content,function(i,j){		
				var text = content[i].typeContent;
		           ctt += "<a role='button' class='btn' onclick='add(text)' href='#'>"+content[i].typeContent+"</a>&nbsp;";		    
			});			
			 tbData.typeContent = ctt;		
			jsonstr_qc2.push(tbData);					
	});	
	}
	
var result=[];	 //存放原始数据
var result2=[];	 //存放处理的数据
//获取条件
function add(obj){
	var flag=false;	
	for(var i=0;i<result.length;i++)
	{			
		if(result[i]==obj){
			flag = true;
		}		
	}
	if(!flag){	          
		result.push(obj);		
	}
	var temp = chuli(result);  //数据处理展示
	$("#chooseResult").html("");
	$("#chooseResult").append(temp);
} 

function chuli(obj){
	var temp=[];
	for(var i=0;i<obj.length;i++)
	{			
	   var ctt = "<a role='button' onclick='del(text)'>"+obj[i]+" <font color='#FF0000'>X</font></a>&nbsp;&nbsp;&nbsp;&nbsp;";
	   temp.push(ctt);
	}
	return temp;
}

//删除条件
function del(obj){	
	var ss = obj.substring(0,obj.length-2);	
	removeByValue(result,ss);
	var temp = chuli(result);  //数据处理展示
	$("#chooseResult").html("");
	$("#chooseResult").append(temp);
	
}

//删除数组数据
function removeByValue(arr, val) {
  for(var i=0; i<arr.length; i++) {
	if(arr[i] == val) {
	  arr.splice(i, 1);
	  break;
	}
  }
}


//查询实时监测详情
$("#xq_search").on("click", function() {  
     alert("请选择查询条件！");
	 
});

//查询实时车辆监测详情
$("#car_search").on("click", function() {  
     alert("请输入车牌号！");
	 
});

// 选择查询条件事件
/* var names = "";
function getQueryCriteria(){
	
	$.ajax(function(){
		
		success:function(data){
			var htmlName = "";
			$.each(data, function(k,v){
				var name = data[k].name;
				htmlName += <a href="add(name)">name</a> + "  ";
			})
			
		}
	})
	
	
}*/

	
//初始化实时曲线图(默认)
$("#modal-658647").on("click", function() {  
	var chart = new Highcharts.Chart('line-chart', {
    title: {
        text: '',
        x: -20
    },
    subtitle: {
        text: '',
        x: -20
    },
	credits: { enabled:false},  
    xAxis: {
        categories: ['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00'
		, '12:00', '13:00', '14:00','15:00','16:00', '17:00','18:00', '19:00','20:00', '21:00', '22:00', '23:00']
    },
    yAxis: {
        title: {
            //text: '温度 (°C)'
			text: '温度1 (°C)'
        },
        plotLines: [{
            value: 0,
            width: 1,
            color: '#808080'
        }]
    },
    tooltip: {
        valueSuffix: '°C'
    },
    legend: {
        layout: 'vertical',
        align: 'right',
        verticalAlign: 'middle',
        borderWidth: 0
    },
    series: [{
        name: '温度1',
        data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6,
		       8.0,3.9, 2.5, 1.5, 11.2, 2.5, 15.2, 26.5, 8.3, 19.3, 10.9, 9.6]
    }]
   });	 
});

	
	
